import scrapy
from tianshan.items import TianshanItem
from scrapy.http import Request

class LessonSpider(scrapy.Spider):
    name = 'lesson'
    allowed_domains = ['hellobi.com']
    start_urls = ['https://edu.hellobi.com/course/311']

    def parse(self, response):
        item=TianshanItem()
        item["title"]=response.xpath("//ol[@class='breadcrumb']/li[@class='active']/text()").extract()
        item["link"]=response.xpath("//ul[@class='nav nav-tabs']/li[@class='active']/a/@href").extract()
        item["stu"]=response.xpath("//span[@class='course-view']/text()").extract()
        yield item # 传送给pipelines进行处理,注意要到settings.py中开启Item_pipelines
        for i in range(1,311):
            url="https://edu.hellobi.com/course/"+str(i)
            url=Request(url,callback=self.parse)
            yield url # 发出请求